(function () {
    let arid = window.location.search.split('=')[1];
    let title = document.querySelector('#title');
    let tags = document.querySelector('#tags');
    let articleWrap = document.querySelector('.article-wrap');
    let eidavaters = document.querySelectorAll('img.eidavater');
    let enames = document.querySelectorAll('.ename');
    let artictime = document.querySelector('.artictime');

    // 文章详情
    axios.get('/api/alpage', {
        params: { arid }
    }).then(res => {
        console.log(res);
        let arcontent = res.data.aInfo[0].content;
        let time = res.data.aInfo[0].addtimes;
        // 获取当前时间
        let d = new Date();
        let newtimes = d.getTime();
        let oldtimes = Date.parse(time);
        let goaltime = Math.floor((newtimes - oldtimes) / 1000 / 60 / 60 / 24);
        if (res.data.code === 1) {
            articleWrap.innerHTML = arcontent;
            title.innerHTML = res.data.aInfo[0].title;
            tags.innerHTML = res.data.aInfo[0].tags;
            artictime.innerHTML = goaltime + '天前从PC网页端发布';

            enames.forEach(itemname => {
                itemname.innerHTML = res.data.aInfo[0].username;
            })
            eidavaters.forEach(item => {
                item.src = res.data.aInfo[0].avater;
            })
        }
    }).catch(err => {
        console.error(err);
    })


})();